	//카테고리
	function clsClubMy_SCategory(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubMy_SCategory.prototype = {
		_init: function(){
			var $layer = $("section#club_my>section div form div.key_ch select:eq(0)");
			this._HTMLDom = {
				"$layer": $layer	
			}	
			$layer.empty();
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display();	
		}	
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.empty();
			
			for(var i=0;i<this.listData.length;++i){
				$layer.append("<option>"+ this.listData[i]["카테고리명"] +"</option>");
			}
		}
		, $getSelect: function(){
			return this._HTMLDom["$layer"];	
		}
		, setIdx: function(n){
			var $layer = this._HTMLDom["$layer"];			
			$layer.find("option").eq(n).prop("selected", true);
			$layer.selectmenu("refresh");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];			
			var n = $layer.find("option").index($layer.find("option:selected"));				
			return this.listData[n]["카테고리키"];
		}
	}
	
	//검색종류
	function clsClubMy_SType(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubMy_SType.prototype = {
		_init: function(){
			var $layer = $("section#club_my>section div form div.key_ch select:eq(1)");
			this._HTMLDom = {
				"$layer": $layer	
			};
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];			
			var n = $layer.find("option").index($layer.find("option:selected"));	
			return n;
		}
		, $getSelect: function(){
			return this._HTMLDom["$layer"];	
		}
	}
	
	//검색어
	function clsClubMy_SText(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubMy_SText.prototype = {
		_init: function(){
			var $layer = $("section#club_my>section div form div.se_area");
			this._HTMLDom = {
				"$layer": $layer	
			}	
			$layer.find("input:text").val("");
		}	
		, $getBtnSearch: function(){
			return this._HTMLDom["$layer"].find("div.ser_btn");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.find("input:text").val();	
		}
	}
	
	//카테고리동호회
	function clsClubMy_Category(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubMy_Category.prototype = {
		_init: function(){
			var $layer = $("section#club_my>section div.gallery_list ul");
			this._HTMLDom = {
				"$layer": $layer	
				, "$element": $layer.find("li:first")
				, "$empty": $layer.find("li:first")				
			}			
			$layer.empty();
		}	
		, setList: function(thisData){
			if(!this.listData) this.listData = [];	
			this.push(thisData);
		}
		, push: function(thisData){
			var thisClass = this;
			var $element = this._HTMLDom["$element"];
			var $tmp = [];
			
			for(var i=0;i<thisData.length;++i){
				$tmp.push($element.clone(true));
				$tmp[i].find("img").attr("src", _util.getDefaultClubImage(thisData[i]["이미지"]));
       		$tmp[i].find("h3").html("<em>("+ thisData[i]["카테고리"] +")</em>"+ thisData[i]["동호회명"]);
       		$tmp[i].find("p:eq(0)").html("매니저 :&nbsp;"+ thisData[i]["닉네임"]);
       		$tmp[i].find("p:eq(1)").html(thisData[i]["동호회설명"]);
       		$tmp[i].find("p:eq(2)").html("회원수 : " + thisData[i]["회원수"] + "명");
       		$tmp[i].find("time").html(_util.fDateYmd(thisData[i]["개설일"]) +"&nbsp;"+ _util.fTime(thisData[i]["개설시간"]));
				thisClass.listData.push(thisData[i]);
			}
			
			this.display($tmp);
		}
		, display: function(thisData){
			var $layer = this._HTMLDom["$layer"];
					
			for(var i=0;i<thisData.length;++i){
				$layer.append(thisData[i]);	
			}
		}
		, reset: function(){
			this.listData = [];			
			this._HTMLDom["$layer"].empty();
		}
		, $getBtnMore: function(){		
			return this._HTMLDom["$layer"].parent().parent().find("div.btn_more");
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];	
		}
		, getListCount: function(){
			if(!this.listData) return 0;
			return this.listData.length;
		}
	}
	
	//데이터연동		
	function clsComm_ClubMy(){
		this.category = null;
		this.categoryClubList = null;
		this.categoryClubListPageData = null;
		this.categoryClubListRequest = null;
		this._init();
	}	
	clsComm_ClubMy.prototype = {
		_init: function(){
			this.category = {					
					"카테고리키": null
					, "카테고리명": null
			}
			this.categoryClubListRequest = {
				"카테고리키": null
				, "페이지": null
				, "검색어":null
				, "검색종류":null
			}		
			
			this.categoryClubListPageData = {
				"현재페이지": null
				, "전체수": null
				//, "페이지당수": 10
				//, "블럭당페이지": 1
			}
		}
//------------------------ 카테고리구분------------------------//		
		, getCategory: function(){
			var thisClass = this;
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename", "getCategoryList");   
			      
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		        		
				thisClass.category = [];
				var items = ret["msp"]["contents"]["items"]
				if(items){
					if(!items.length){
						items = new Array(items);
					}
					for(var i=0;i<items.length;i++){
						thisClass.category.push({
							"카테고리키": items[i]["categoryId"]
							, "카테고리명": items[i]["categoryName"]
						});
					}
					
					$(thisClass).trigger("evtFinishCategory");
				}
        	}, function($err) {
				alert($err);
			});
		}
		, getCategoryData: function(){
			return this.category;
		}
//------------------------ 카테고리구분------------------------//	
//------------------------ 카테고리별동호회------------------------//		
		, getCategoryClubList: function(){
			var thisClass = this;
			
			var szPage = this.categoryClubListRequest["페이지"];	
			var szCategory = this.categoryClubListRequest["카테고리키"];	
			var szSearchType = this.categoryClubListRequest["검색종류"];
			var szSearchText = this.categoryClubListRequest["검색어"];
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CL001");
        	objJson.putPub("servicename", "searchClub");   
        	objJson.putPub("listcount", 10);   
        	objJson.putPub("currpageno", szPage);   
        					
        	objJson.putParameter("categoryId", szCategory);
        	objJson.putParameter("searchOption", szSearchType);
        	objJson.putParameter("searchValue", szSearchText);
        	objJson.putParameter("sortBy", "2");
        	objJson.putParameter("sortOption", "1");
        	objJson.putParameter("userId", _util.getLogin("아이디"));
			
			cm.requestGet(objJson.getJsonString(), function(ret){
        	
        		thisClass.categoryClubList = [];
        		
        		var items = ret["msp"]["contents"]["items"];
        		
        		if(items){        			
        			thisClass.categoryClubListPageData["전체수"] = ret["msp"]["contents"]["@totalcount"];
        			
					if(!items.length){
						items	= new Array(items);
					}
					for(var i=0;i<items.length;i++){
						var timelag = "";
						if(items[i]["clubBoard"]) timelag = items[i]["clubBoard"]["timelag"] ;
						
						thisClass.categoryClubList.push({
							"동호회키": items[i]["clubSeq"]
							, "이미지":  items[i]["logoUrl"]
							, "동호회명": items[i]["clubName"]
							, "아이디": items[i]["userMaster"]["userId"]
							, "닉네임": items[i]["userMaster"]["nickname"]
							, "회원수": items[i]["memberCnt"]
							, "댓글수": items[i]["newBoardCnt"]
							, "동호회설명": items[i]["clubDesc"]
							, "카테고리": items[i]["clubCategoryMaster"]["categoryName"]
							, "개설일": items[i]["regDate"]
							, "개설시간": items[i]["regTime"]
						});
					}					
				}
								
        		$(thisClass).trigger("evtFinishCategoryClubList");
        
        	}, function($err) {
				alert($err);
			});	
		}
		, getCategoryClubData: function(){
			return this.categoryClubList;
		}
		, getCategoryClubPageData: function(){
			return this.categoryClubListPageData;
		}
		, setcategoryClubListRequest: function(key, val){
			this.categoryClubListRequest[key] = val;
		}
		, getcategoryClubListRequest: function(key){
			return this.categoryClubListRequest[key];
		}
//------------------------ 카테고리별동호회-----------------------------//					
	}
	
	//컨트롤파일
	function ClubMy(){				
		this.objComm = null;	
		this.objClubSCategory = null;		
		this.objClubSType = null;
		this.objClubSText = null;			
		this.objClubCategory = null;		
	};
	
	ClubMy.prototype = {
	    onPageShow : function() {	    
	    	$("a").attr("href", "").attr("data-rel", "");      
	    	$("button").attr("data-role", "none");
	    	this._init();	    		    	
	    }
	    , _init: function(){	    		    	
	    	
	    	this.objComm = new clsComm_ClubMy();
	     	this.objClubSCategory = new clsClubMy_SCategory();		
			this.objClubSType = new clsClubMy_SType();
			this.objClubSText = new clsClubMy_SText();
			
			this.objClubCategory = new clsClubMy_Category();
			
	      this.getParam();
	    	
	    	this._role();
	       
	      	this._bind();
	      	this._eventFinish();     	
	      	
	      	//카테고리 조회
	     	this.objComm.getCategory();
	     	this.spinStart();
	    }
	    , _start: function(){
	    	
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	// 카테고리구분 조회 완료이벤트
			$(this.objComm).bind("evtFinishCategory", function(event){
				
				var thisData = thisClass.objComm.getCategoryData();
								
				thisClass.objClubSCategory.setList(thisData);
				
				// 카테고리 전체로 default 설정
				thisClass.objClubSCategory.setIdx(0);
				
				//동호회목록 조회				
				thisClass.objComm.setcategoryClubListRequest("카테고리키","0");
				thisClass.objComm.setcategoryClubListRequest("검색종류","0");
				thisClass.objComm.setcategoryClubListRequest("검색어","");
				thisClass.objComm.setcategoryClubListRequest("페이지",1);
				thisClass.objComm.getCategoryClubList();								
			});
			
			// 카테고리목록 조회 완료이벤트
			$(this.objComm).bind("evtFinishCategoryClubList", function(){
				var thisData = this.getCategoryClubData();
				var totalCnt = thisClass.objComm.getCategoryClubPageData();
				thisClass.objClubCategory.setList(thisData);	
				thisClass.spinEnd();			
				
				//더보기 버튼 
		 		if(thisClass.objClubCategory.getListCount() >= totalCnt["전체수"]) {
		 			thisClass.objClubCategory.$getBtnMore().hide();
		 		}else {
		 			thisClass.objClubCategory.$getBtnMore().show();
		 		}
			});
	    }
		 , _bind: function(){
		 	var thisClass = this;
		 	
		 	// 카테고리목록 조회 완료이벤트
			$(this.objComm).bind("evtFinishCategoryClubList", function(){
				var thisData = this.getCategoryClubData();
				var totalCnt = thisClass.objComm.getCategoryClubPageData();
				thisClass.objClubCategory.setList(thisData);	
				thisClass.spinEnd();			
				
				//더보기 버튼 
		 		if(thisClass.objClubCategory.getListCount() >= totalCnt["전체수"]) {
		 			thisClass.objClubCategory.$getBtnMore().hide();
		 		}else {
		 			thisClass.objClubCategory.$getBtnMore().show();
		 		}
			});
			
			//검색버튼 이벤트
		 	this.objClubSText.$getBtnSearch().click(function(event){
		 		var sCategory = thisClass.objClubSCategory.getValue();
		 		var sType = thisClass.objClubSType.getValue();
		 		var sText = thisClass.objClubSText.getValue();
		 		
		 		thisClass.objClubCategory.reset();
		 		
		 		thisClass.objComm.setcategoryClubListRequest("카테고리키",sCategory);
		 		thisClass.objComm.setcategoryClubListRequest("검색종류",sType);
		 		thisClass.objComm.setcategoryClubListRequest("검색어",sText);
		 		thisClass.objComm.setcategoryClubListRequest("페이지",1);
		 		thisClass.objComm.getCategoryClubList();
		 	});		 	
		 	
		 	//더보기
		 	this.objClubCategory.$getBtnMore().click(function(event){
		 		var page = thisClass.objComm.getcategoryClubListRequest("페이지");
		 		thisClass.objComm.setcategoryClubListRequest("페이지",(page+1));
		 		thisClass.objComm.getCategoryClubList();
		 		thisClass.spinStart();
		 	});
		 	
		 	//동호회 홈
		 	$("section#club_my footer nav ul li:eq(0)").click(function(event){
		 		event.preventDefault();
		 		_gf.CLUB_DATA = {};
		 		$.mobile.changePage("club.html","slide",true);
		 	});
		 	
		 	//나의가입동호회
		 	$("section#club_my footer nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		
		 		if(!_util.getLogin("아이디")){
		 			_gf.LOGIN_DATA.loginAfterUrl = "self_club.html";
		 			thisClass.goLogin();
		 			return;
		 		}
		 		
		 		_gf.CLUB_DATA = {};
		 		$.mobile.changePage("club_my.html","slide",true); 
		 	});
		 	
		 	//메뉴
		 	$("section#club_my nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#club_my nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//개별동호회 이동-카테고리목록
		 	this.objClubCategory.$getLayer().on("click", "a", function(event){
		 		event.preventDefault();
		 		var n = thisClass.objClubCategory.$getLayer().find("a").index($(this));
		 		
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.objClubCategory.listData[n]["동호회키"]
		 		}
		 		
		 		$.mobile.changePage("self_club.html","slide",true); 
		 	});		 	
		 }
		 , getParam: function(){
	    	
	    }
	    , _role: function(){
	    		
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}	